﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;

namespace Galaktika.BI.Silverlight.Runtime
{
       public static class Clipboard
       {
           public static void SetClipboardText(string text)
           {
               var clipboard = (ScriptObject)HtmlPage.Window.GetProperty("clipboardData");
               
               if (clipboard != null)
               {
                   bool success = (bool)clipboard.Invoke("setData", "text", text);
                   if (!success)
                   {
                       HtmlPage.Window.Alert(Galaktika.BI.Silverlight.Localization.Msg_UnableCopy);
                   }
               }
               else
               {
                   HtmlPage.Window.Alert(Galaktika.BI.Silverlight.Localization.Msg_ClipboardUnavailable);
               }
           }
   
           public static string GetClipboardText()
           {
               string text = string.Empty;
               
               var clipboard = (ScriptObject)HtmlPage.Window.GetProperty("clipboardData");
   
               if (clipboard != null)
               {
                   text = (string)clipboard.Invoke("getData", "text");
               }
               else
               {
                   HtmlPage.Window.Alert(Galaktika.BI.Silverlight.Localization.Msg_ClipboardUnavailable);
               }
               return text;
           }
       }

}
